home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Source Code
/
Visual Basic Source Code.iso
/
vbsource
/
vbench
/
vbench.frm
< prev
next >
Wrap
Text File
|
1994-07-13
|
14KB
|
472 lines
VERSION 2.00
Begin Form Vbench
BackColor = &H00C0C0C0&
Caption = "VBench"
ClientHeight = 3228
ClientLeft = 1584
ClientTop = 660
ClientWidth = 5172
Height = 3648
Left = 1536
LinkTopic = "Form1"
ScaleHeight = 3228
ScaleWidth = 5172
Top = 288
Width = 5268
Begin TextBox Text1
Height = 372
Index = 4
Left = 2520
TabIndex = 8
Text = "Text1"
Top = 2160
Width = 2412
End
Begin TextBox Text1
Height = 372
Index = 3
Left = 2520
TabIndex = 7
Text = "Text1"
Top = 1680
Width = 2412
End
Begin TextBox Text1
Height = 372
Index = 2
Left = 2520
TabIndex = 6
Text = "Text1"
Top = 1200
Width = 2412
End
Begin TextBox Text1
Height = 372
Index = 1
Left = 2520
TabIndex = 5
Text = "Text1"
Top = 720
Width = 2412
End
Begin TextBox Text1
Height = 372
Index = 0
Left = 2520
TabIndex = 4
Text = "Text1"
Top = 240
Width = 2412
End
Begin CommandButton Command1
Caption = "E&xit"
Height = 372
Index = 3
Left = 3840
TabIndex = 3
Top = 2760
Width = 1092
End
Begin CommandButton Command1
Caption = "&Populate"
Height = 372
Index = 2
Left = 2640
TabIndex = 2
Top = 2760
Width = 1092
End
Begin CommandButton Command1
Caption = "&Select"
Height = 372
Index = 1
Left = 1440
TabIndex = 1
Top = 2760
Width = 1092
End
Begin CommandButton Command1
Caption = "&Update"
Height = 372
Index = 0
Left = 240
TabIndex = 0
Top = 2760
Width = 1092
End
Begin Label Label1
BackColor = &H00C0C0C0&
Caption = "Parameter QueryDef"
ForeColor = &H00FF0000&
Height = 252
Index = 4
Left = 240
TabIndex = 13
Top = 2160
Width = 2412
End
Begin Label Label1
BackColor = &H00C0C0C0&
Caption = "Static QueryDef"
ForeColor = &H00FF0000&
Height = 252
Index = 3
Left = 240
TabIndex = 12
Top = 1680
Width = 2412
End
Begin Label Label1
BackColor = &H00C0C0C0&
Caption = "Inline VB SQL"
ForeColor = &H00FF0000&
Height = 252
Index = 2
Left = 240
TabIndex = 11
Top = 1200
Width = 2412
End
Begin Label Label1
BackColor = &H00C0C0C0&
Caption = "Dynaset FindFirst"
ForeColor = &H00FF0000&
Height = 252
Index = 1
Left = 240
TabIndex = 10
Top = 720
Width = 2412
End
Begin Label Label1
BackColor = &H00C0C0C0&
Caption = "ISAM Table Seek"
ForeColor = &H00FF0000&
Height = 252
Index = 0
Left = 240
TabIndex = 9
Top = 240
Width = 2412
End
End
'Declarations
Option Explicit
Dim db As database
Dim tbl As Table
Dim dyna As dynaset
Dim qd As querydef
Dim foo As Integer
Declare Function GetTickCount Lib "User" () As Long
Sub CloseDb ()
On Error Resume Next
dyna.Close
tbl.Close
qd.Close
db.Close
DoEvents
End Sub
Sub Command1_Click (Index As Integer)
Dim TimeCount As Long, TimeStart As Long
Dim foobar As Integer, foo As Integer
ReDim cost(5) As Double
TimeCount = 0
'Set the hourglass
Screen.MousePointer = 11
Select Case Index
'Update Operations ======================================
'The objective here is to examine 1000 out of 10,000 records,
'and modify those that match a given criteria - about 200 writes
Case 0
Me.Caption = "VBench: Update Operation Benchmarks"
FileCopy "C:\vb\IoTest.Mdb", "C:\vb\IoTest.Bak"
'Seeks and indexed sequential updates ---------------
'Open the database logicals
OpenDb
'Start the clock
TimeStart = GetTickCount()
'Use transactions for speed
BeginTrans
'Jump to first ID using a fast seek
tbl.Seek ">=", 5000
'Continue searching till eof or break
Do Until tbl.EOF
'Test if reached top of range
If tbl!id < 6000 Then
'Test if record meets change criteria
If tbl!cost > 30 And tbl!cost < 40 Then
tbl.Edit
tbl!cost = tbl!cost * .9
tbl.Update
End If
Else
'Exit if past top of range
Exit Do
End If
'Get the next record
tbl.MoveNext
Loop
CommitTrans
'Stop the clock and report
TimeCount = GetTickCount() - TimeStart
Text1(0) = Format$(TimeCount / 1000, "##0.00")
CloseDb
'Dynaset FindFirst ---------------------------------------
'Start each iteration with same file
FileCopy "C:\vb\IoTest.bak", "C:\vb\IoTest.mdb"
'Open the data logicals
OpenDb
'Start The Clock
TimeStart = GetTickCount()
'Use transactions for speed
BeginTrans
'Jump to first record
dyna.FindFirst "Id >= 5000"
'Continue searching till eof or break
Do Until dyna.EOF
'Test if reached top of range
If dyna!id < 6000 Then
'Test if record meets change criteria
If dyna!cost > 30 And dyna!cost < 40 Then
dyna.Edit
dyna!cost = dyna!cost * .9
dyna.Update
End If
Else
'Exit loop if past top of range
Exit Do
End If
'Get the next record
dyna.MoveNext
Loop
CommitTrans
'Stop the clock and report
TimeCount = GetTickCount() - TimeStart
Text1(1) = Format$(TimeCount / 1000, "##0.00")
CloseDb
'Test SQL processing with inline VB code ----------
'Start each iteration with same file
FileCopy "C:\vb\IoTest.bak", "C:\vb\IoTest.mdb"
'Open the database logicals
OpenDb
'Start The Clock
TimeStart = GetTickCount()
'Execute the statement on databse DB
db.Execute "Update testtable Set Cost = Cost *.9 where cost > 30 and cost < 40 and id >= 5000 and id < 6000 and id/2 = id\2"
'Stop the clock and report
TimeCount = GetTickCount() - TimeStart
Text1(2) = Format$(TimeCount / 1000, "##0.00")
CloseDb
'Test SQL processing with Stored QueryDef -------
'Start each iteration with same file
FileCopy "C:\vb\IoTest.bak", "C:\vb\IoTest.mdb"
'Open the database logicals
OpenDb
'Store the procedure before starting the clock
Set qd = db.CreateQueryDef("TestQd", "Update testtable Set Cost = Cost *.9 where cost > 30 and Cost < 40 and id >= 5000 and id < 6000")
qd.Close
'Start The Clock
TimeStart = GetTickCount()
'Use Transactions for speed
BeginTrans
'Execute the querydef on database DB
db.Execute "TestQd"
CommitTrans